#include "SMPPSubmitSM.hpp"

using namespace smpp::pdu;

SubmitSM::SubmitSM(const Header &nHeader,
const CoctetString &nServiceType,
const quint8 nSourceAddrTON,
const quint8 nSourceAddrNPI,
const CoctetString &nSourceAddr,
const quint8 nDestAddrTON,
const quint8 nDestAddrNPI,
const CoctetString &nDestAddr,
const quint8 nEsmClass,
const quint8 nProtocolId,
const quint8 nPriorityFlag,
const CoctetString &nScheduleDeliveryTime,
const CoctetString &nValidityPeriod,
const quint8 nRegisteredDelivery,
const quint8 nReplaceIfPresentFlag,
const quint8 nDataCoding,
const quint8 nSMDefaultMsgId,
const quint8 nSMLength,
const octetString &nShortMessage,
const MessageSubmissionRequestTLVs &nMessageSubmissionRequestTLVs):
Header(nHeader),
_ServiceType(nServiceType),
_SourceAddrTON(nSourceAddrTON),
_SourceAddrNPI(nSourceAddrNPI),
_SourceAddr(nSourceAddr),
_DestAddrTON(nDestAddrTON),
_DestAddrNPI(nDestAddrNPI),
_DestAddr(nDestAddr),
_EsmClass(nEsmClass),
_ProtocolId(nProtocolId),
_PriorityFlag(nPriorityFlag),
_ScheduleDeliveryTime(nScheduleDeliveryTime),
_ValidityPeriod(nValidityPeriod),
_RegisteredDelivery(nRegisteredDelivery),
_ReplaceIfPresentFlag(nReplaceIfPresentFlag),
_DataCoding(nDataCoding),
_SMDefaultMsgId(nSMDefaultMsgId),
_SMLength(nSMLength),
_ShortMessage(nShortMessage),
MessageSubmissionRequestTLVs(nMessageSubmissionRequestTLVs){}

SubmitSM::SubmitSM(const SubmitSM &nSubmitSM):
Header(nSubmitSM),
_ServiceType(nSubmitSM.getServiceType()),
_SourceAddrTON(nSubmitSM.getSourceAddrTON()),
_SourceAddrNPI(nSubmitSM.getSourceAddrNPI()),
_SourceAddr(nSubmitSM.getSourceAddr()),
_DestAddrTON(nSubmitSM.getDestAddrTON()),
_DestAddrNPI(nSubmitSM.getDestAddrNPI()),
_DestAddr(nSubmitSM.getDestAddr()),
_EsmClass(nSubmitSM.getEsmClass()),
_ProtocolId(nSubmitSM.getProtocolId()),
_PriorityFlag(nSubmitSM.getPriorityFlag()),
_ScheduleDeliveryTime(nSubmitSM.getScheduleDeliveryTime()),
_ValidityPeriod(nSubmitSM.getValidityPeriod()),
_RegisteredDelivery(nSubmitSM.getRegisteredDelivery()),
_ReplaceIfPresentFlag(nSubmitSM.getReplaceIfPresentFlag()),
_DataCoding(nSubmitSM.getDataCoding()),
_SMDefaultMsgId(nSubmitSM.getSMDefaultMsgId()),
_SMLength(nSubmitSM.getSMLength()),
_ShortMessage(nSubmitSM.getShortMessage()),
MessageSubmissionRequestTLVs(nSubmitSM){}

void SubmitSM::setServiceType(const CoctetString& sServiceType){
	_ServiceType = sServiceType;
}

const CoctetString &SubmitSM::getServiceType() const{
	return _ServiceType;
}

void SubmitSM::setSourceAddrTON(const quint8 nSourceAddrTON){
	_SourceAddrTON = nSourceAddrTON;
}

const quint8 SubmitSM::getSourceAddrTON() const{
	return _SourceAddrTON;
}

void SubmitSM::setSourceAddrNPI(const quint8 nSourceAddrNPI){
	_SourceAddrNPI = nSourceAddrNPI;
}

const quint8 SubmitSM::getSourceAddrNPI() const{
	return _SourceAddrNPI;
}

void SubmitSM::setSourceAddr(const CoctetString &sSourceAddr){
	_SourceAddr = sSourceAddr;
}

const CoctetString &SubmitSM::getSourceAddr() const{
	return _SourceAddr;
}

void SubmitSM::setDestAddrTON(const quint8 nDestAddrTON){
	_DestAddrTON = nDestAddrTON;
}

const quint8 SubmitSM::getDestAddrTON() const{
	return _DestAddrTON;
}

void SubmitSM::setDestAddrNPI(const quint8 nDestAddrNPI){
	_DestAddrNPI = nDestAddrNPI;
}

const quint8 SubmitSM::getDestAddrNPI() const{
	return _DestAddrNPI;
}

void SubmitSM::setDestAddr(const CoctetString& sDestAddr){
	_DestAddr = sDestAddr;
}
const CoctetString &SubmitSM::getDestAddr() const{
	return _DestAddr;
}

void SubmitSM::setEsmClass(const quint8 nEsmClass){
	_EsmClass = nEsmClass;
}

const quint8 SubmitSM::getEsmClass() const{
	return _EsmClass;
}

void SubmitSM::setProtocolId(const quint8 nProtocolId){
	_ProtocolId = nProtocolId;
}

const quint8 SubmitSM::getProtocolId() const{
	return _ProtocolId;
}

void SubmitSM::setPriorityFlag(const quint8 nPriorityFlag){
	_PriorityFlag = nPriorityFlag;
}

const quint8 SubmitSM::getPriorityFlag() const{
	return _PriorityFlag;
}

void SubmitSM::setScheduleDeliveryTime(
	const CoctetString &sScheduleDeliveryTime){
		_ScheduleDeliveryTime = sScheduleDeliveryTime;
}

const CoctetString& SubmitSM::getScheduleDeliveryTime() const{
	return _ScheduleDeliveryTime;
}

void SubmitSM::setValidityPeriod(const CoctetString &sValidityPeriod){
	_ValidityPeriod = sValidityPeriod;
}

const CoctetString &SubmitSM::getValidityPeriod() const{
	return _ValidityPeriod;
}

void SubmitSM::setRegisteredDelivery(const quint8 nRegisteredDelivery){
	_RegisteredDelivery = nRegisteredDelivery;
}

const quint8 SubmitSM::getRegisteredDelivery() const{
	return _RegisteredDelivery;
}

void SubmitSM::setReplaceIfPresentFlag(
	const quint8 nReplaceIfPresentFlag){
		_ReplaceIfPresentFlag = nReplaceIfPresentFlag;
}

const quint8 SubmitSM::getReplaceIfPresentFlag() const{
	return _ReplaceIfPresentFlag;
}

void SubmitSM::setDataCoding(const quint8 nDataCoding){
	_DataCoding = nDataCoding;
}

const quint8 SubmitSM::getDataCoding() const{
	return _DataCoding;
}

void SubmitSM::setSMDefaultMsgId(const quint8 nSMDefaultMsgId){
	_SMDefaultMsgId = nSMDefaultMsgId;
}

const quint8 SubmitSM::getSMDefaultMsgId() const{
	return _SMDefaultMsgId;
}

void SubmitSM::setSMLength(const quint8 nSMLength){
	_SMLength = nSMLength;
}

const quint8 SubmitSM::getSMLength() const{
	return _SMLength;
}

void SubmitSM::setShortMessage(const octetString &aShortMessage){
	_ShortMessage = aShortMessage;		
}

const octetString &SubmitSM::getShortMessage() const{
	return _ShortMessage;
}

void SubmitSM::calcCommandLength(){
	_CommandLength = 33 + _ServiceType.size() + _SourceAddr.size() +
		_DestAddr.size() + _ScheduleDeliveryTime.size() +
		_ValidityPeriod.size() + _SMLength + 
		MessageSubmissionRequestTLVs::getLength();
}
